import Vue from 'vue';
import moment from 'moment';

Vue.directive('scroll', {
	bind(el, binding) {
		let wrapper=el;
		let container=$(el).find('.table-scrollable')[0];
        wrapper.addEventListener('scroll',()=>{
        	let scrollTop=wrapper.scrollTop;
			if (scrollTop+wrapper.clientHeight>=container.clientHeight){
				console.log("loading data")
				binding.value.call(this)
			}
		})
	},
	update(el,val){
		
	}
});
Vue.directive('auotHeight',{
	bind (el,val){
		let windowHeight=$(window).height();
		let deleHeight=val.value;
		$(el).height(windowHeight-deleHeight)
	}
});
Vue.directive('tranTime',{
	bind (el,val){
		if(val.value){
			$(el).html(moment(val.value).format('YYYY/MM/DD HH:mm:ss'));
		}
	}
});